<template>
  <div class="main">
    <table class="tabel">
      <thead class="thead">
        <slot name="head"></slot>
      </thead>

      <tbody class="tbody">
        <slot name="body" v-for="(item, index) in list" :item="item" :index="index"></slot>
      </tbody>
    </table>
  </div>
</template>
<script>
export default {
  name: "myTabel",
  props: {
    list: {
      type: Array,
      required: true
    }
  }
};
</script>

<style lang="scss" scoped>
.main {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  .tabel {
    width: 100%;
    border-collapse: collapse;
    --row-h: 70px;
    // 表头
    .thead {
      color: #fff;
      width: 100%;
      height: 30px;
      font-size: 18px;
      background-color: rgba(0, 0, 0, 0.5);
      border-bottom: 1px solid #000;
      // 表头的每一行
      th {
        width: var(--row-h);
        // padding: 0 10px;
      }
    }
    // 表内容
    .tbody {
      width: 100%;
      // 每一行
      tr {
        width: 100%;
        height: var(--row-h);
        border-bottom: 1px solid #999;
        // 单独 设置图片 让其居中
        .img-box {
          height: var(--row-h);
          width: 100%;
          display: flex;
          align-items: center;
          justify-content: center;
          .img {
            width: 60px;
            height: 60px;
            border-radius: 5px;
            overflow: hidden;
            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
            }
          }
        }
        // 公共行 样式
        td {
          width: 50px;
          height: 100%;
          line-height: 50px;
          // padding: 0 10px;
          text-align: center;
        }
      }
    }
  }
}
</style>